package com.acmetelecom;

import org.joda.time.DateTime;

public class Call {
    private CallEvent start;
    private CallEvent end;
    private int peakSeconds;
    private int offpeakSeconds;

    public Call(CallEvent start, CallEvent end) {
        this.start = start;
        this.end = end;
        this.peakSeconds = 0;
        this.offpeakSeconds = 0;
        calculateDuration();
    }

    private void calculateDuration() {
    	DurationCalculator d = new DurationCalculator(start.time(),end.time());
    	this.peakSeconds = d.getPeakSeconds();
    	this.offpeakSeconds = d.getOffPeakSeconds();    	
	}
    
    public String callee() {
        return start.getCallee();
    }

    public int durationSeconds() {
        return (int) (((end.time().getMillis() - start.time().getMillis()) / 1000));
    }

    public String date() {
        return new DateTime(start.time()).toString();
    }

    public DateTime startTime() {
        return new DateTime(start.time());
    }

    public DateTime endTime() {
        return new DateTime(end.time());
    }
    
    public int peakDurationSeconds() {
		return this.peakSeconds;
	}

	public int offpeakDurationSeconds() {
		return this.offpeakSeconds;
	}
}
